package com.mig.tg.report.sql;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.mig.tg.report.ReportSQLBuilder;
import com.mig.tg.report.model.Proposal;

public class DefaultProposalSQLGenertor implements ReportSQLBuilder{

	private SelectSQLBuilder builder= new SelectSQLBuilderImpl();
	Map<PropertyField,FieldMapping<PropertyField>> mapping = 
			new HashMap<PropertyField,FieldMapping<PropertyField>>();
	@Override
	public String buildSQL(Proposal proposal) {
		
		
		List<Integer> properties = new ArrayList<Integer>();
		List<Integer> datas = new ArrayList<Integer>();
		
		for(Integer property:properties){
			PropertyField field = PropertyField.fromValue(property);
			
			FieldMapping<PropertyField> fMapping = mapping.get(field);
			
			if(fMapping != null){
				for(PropertyField innerP:fMapping.values){
					builder.addSelectColumn(innerP.getDisplay());
				}
			}else{
				builder.addSelectColumn(field.getDisplay());
			}
		}
		
		for(Integer data:datas){
			DataField field = DataField.fromValue(data);			
			builder.addSelectColumn(field.getDisplay());			
		}

		
		return null;
	}

	public String createSQL(Proposal proposal ,boolean isGroupByDevice,boolean isGroupByAdNetworkd){
		
		return null;
	}
	
	public void init(){
		
		mapping.put(PropertyField.ADGROUPKEYWORDID, 
				new FieldMapping<PropertyField>(PropertyField.ADGROUPKEYWORDID, 
						PropertyField.ADGROUPID,PropertyField.KEYWORDID,PropertyField.MATCHTYPE));
		
		
	}
	
}
